package com.example;

import com.common.pattern.pipeline.Result;
import com.common.pattern.pipeline.bo.BusinessContext;
import com.common.pattern.pipeline.service.ExecutorService;
import com.common.pattern.pipeline.utils.SpringUtil;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.util.HashMap;
import java.util.concurrent.TimeUnit;

/**
 * @author admin
 */
@SpringBootApplication
public class DesignPatternApplication {

    public static void main(String[] args) throws InterruptedException {
        SpringApplication.run(DesignPatternApplication.class, args);

        TimeUnit.SECONDS.sleep(2);
        //testPipeline();
    }

    private static void testPipeline() {
        ExecutorService executorService = SpringUtil.getBean(ExecutorService.class);
        BusinessContext pipelineContext = new BusinessContext();
        pipelineContext.setModelId(1L);
        HashMap<String, Object> inputParams = new HashMap<>(2);
        pipelineContext.setInputParams(inputParams);

        inputParams.put("expirationDate", "2023-8-10 11:45:43");
        inputParams.put("factory", "fa♂Q工厂");
        inputParams.put("permittedProduction", "准许生产");
        inputParams.put("QS", "质量安全");
        Result<String> stringResult = executorService.dealSync(pipelineContext);
        System.err.println(stringResult);
    }

}
